package controller;


import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import databean.User;

import model.Model;
import model.UserDAO;


public class ContactsAction extends Action {
	
	private UserDAO		userDAO;
	
	public ContactsAction(Model model) {
		userDAO  = model.getUserDAO();
	}

	public String getName() { return "contacts.do"; }
    
    public String perform(HttpServletRequest request,HttpServletResponse response) {
    
    	
    	List<String> errors = new ArrayList<String>();
        request.setAttribute("errors",errors);
        
        HttpSession session = request.getSession();
        
        
		try {
	        
			if (session.getAttribute("user") == null) {
				return "user-login.do";
			}
			
			request.setAttribute("user",(User) request.getSession(false).getAttribute("user"));
			
			
			User user = (User) request.getSession(false).getAttribute("user");
    	
        return "contacts.jsp";
        
		  } catch (Exception e) {
	        	errors.add(e.getMessage());
	        	return "user-error-list.jsp";
	      }
    }
}
